<?php

#########################################################################
#RECOMMENDED: default link for a knowledge database of your choice#######
#########################################################################

$wikiURL="http://en.wikipedia.org/wiki/";

#########################################################################
#HIGHLY-RECOMMENDED: An array for user permissions.  Future releases may
#                    instate out-of-file modification for root users.
#########################################################################

/***************************************************************

FORMAT:

$users=array(

	'nick!user@host'			=> 'permission',
	'*!*@wikipedia/Yamakiri'		=> 'root'      ,
	'bot!administrator@localhost'		=> 'h-root'    ,
);

***************************************************************/
$users = array(

	'*!*@wikipedia/Yamakiri'		=> 'admin'  ,
	'*!*@wikipedia/PseudoOne'		=> 'admin'  ,
	'*!*@wikipedia/FastLizard4'		=> 'h-admin',
	'*!*@wikipedia/Until-It-Sleeps'		=> 'ignored',
	'*!*@nightshade.toolserver.org'		=> 'ignored',
	'*!*@you.need.to.stfu-kthx.net'		=> 'ignored',
	'*!*@wikipedia/jake-wartenberg'		=> 'trusted',
	'*!*@91.198.174.201'			=> 'ignored',
	'*!*@wikipedia/neurolysis'		=> 'ignored',
	'*!*@wikipedia/soxred93/bot/SoxBot'	=> 'ignored',
	'SoxBot!*@*' 				=> 'ignored',
	'LizardWiki-RC!*@*'			=> 'ignored',
#	'*!*@' 				=> '',
	'*!*@*'		 			=> 'base'  ,

);

#########################################################################
#HIGHLY-RECOMMENDED/REQUIRED: Required if you are using the $userPerms 
#                  array, and highly-recommended if you are not.  The 
#                  following gives the abilities for the canUse access 
#                  checking function
#########################################################################
global $privgroups;

$privgroups[ 'ignored'  ]	      = 0;

$privgroups[ 'base'     ][ 'link'   ] = 1; /*
$privgroups[ 'base'     ][ ''       ] = 1; */

$privgroups[ 's-trusted']               = $privgroups['base'];       #s-trusted inherits base
$privgroups[ 's-trusted'][ 'echo'     ] = 1;
$privgroups[ 's-trusted'][ 'do'       ] = 1;
$privgroups[ 's-trusted'][ 'notice'   ] = 1;

$privgroups[ 'trusted'  ]               = $privgroups['s-trusted']; #trusted inherits s-trusted
$privgroups[ 'trusted'  ][ 'join'     ] = 1;
$privgroups[ 'trusted'  ][ 'part'     ] = 1;
$privgroups[ 'trusted'  ][ 'rejoin'   ] = 1;
$privgroups[ 'trusted'  ][ 'stats'    ] = 1;

$privgroups[ 'trusted'  ][ 'math'     ] = 1; #math is due to be implemented in future releases
$privgroups[ 'trusted'  ][ 'track'    ] = 1; 

$privgroups[ 'v-trusted']               = $privgroups['trusted'];   #v-trusted inherits trusted
$privgroups[ 'v-trusted'][ 'restart'  ] = 1; #to do
$privgroups[ 'v-trusted'][ 'help'     ] = 1; #to do

$privgroups[ 'h-admin'  ]               = $privgroups['v-trusted']; #h-admin inherits v-trusted
$privgroups[ 'h-admin'  ][ 'off'      ] = 1; 
$privgroups[ 'h-admin'  ][ 'on'       ] = 1;
$privgroups[ 'h-admin'  ][ 'raw'      ] = 1;
$privgroups[ 'h-admin'  ][ 'fwrite'   ] = 1;
$privgroups[ 'h-admin'  ][ 'blacklist'] = 1;
$privgroups[ 'h-admin'  ][ 'quit'     ] = 1;
$privgroups[ 'h-admin'  ][ 'amsg'     ] = 1;

$privgroups[ 'admin'    ]               = $privgroups['h-admin'];    #admin inherits h-admin
$privgroups[ 'admin'    ][ 'eval'     ] = 1;
$privgroups[ 'admin'    ][ 'die'      ] = 1;
$privgroups[ 'admin'    ][ 'add'      ] = 1;
$privgroups[ 'admin'    ][ 'remove'   ] = 1; /*
$privgroups[ 'admin'    ][ ''         ] = 1; */

if(!$rehash) {
    function hasPriv($priv) {
        global $privgroups, $users, $d;
        $parsed = $d[0];
        foreach( $users as $user => $group ) {
            if( fnmatch( $user, $parsed/*['n!u@h']*/ ) ) {
                if( isset( $privgroups[$group][$priv] ) ) {
                    return $privgroups[$group][$priv];
                } else {
                    return 0;
                }
            }
        }
        $d[0] = $parsed;
    }
    function showPriv() {
        global $privgroups, $users, $d;
        $parsed = $d[0];
        foreach( $users as $user => $group ) {
            if( fnmatch( $user, $parsed/*['n!u@h']*/ ) ) {
                return "$group";
            } else {
                return "Error getting priv";
            }
        }
    }
}

#########################################################################
#RECOMMENDED: Set the bot's default CTCP responses ######################
#########################################################################

define("CTCPVersion","PHP-YamaBot (Written in PHP 5 by Yamakiri, SudoKing, with excerpts from LizardBot) v{$version} http://code.google.com/p/yamabot/source/browse/trunk/yamabot",TRUE);
$CTCPTime = "Current Time: ". date("h:i:s");
define("CTCPUserinfo","YamaBot is a GNU GPL PHP IRC bot written by Yamakiri.  The source is here: http://code.google.com/p/yamabot/source/browse/trunk/yamabot",TRUE);
define("CTCPClientinfo","I'm YamaBot v{$version} and I support these commands: VERSION TIME USERINFO CLIENTINFO FINGER",TRUE);
define("CTCPFINGER", "YamaBot v{$version}");
#########################################################################
#LEISURE: Pre-define all command line startup parameters ################
#########################################################################

/*
$config = array(
	'botnick'     => "",
	'GECOS'       => "",
	'ident'       => "",
	'debugChan'   => "", #Just type FALSE without quotes if you don't want one
	'autoRejoin'  => "", #yes or no
	'network'     => "",
	'chans'       => "", #comma seperate
	"port"        => ,   #integers don't need quotes
	"NickServPass"=> "", #Might not be such a good idea...
);  
*/
//note these may be defined in another file if you include() it

#########################################################################
#########################################################################
##NOTICE:  REMOVE THE FOLLOWING LINE!  It is to make sure that you, the##
##         user, actually went through the configuration file before   ##
##         run time.  Again, comment out or remove the line below.     ##
##         WHILE YOU'RE HERE:                                          ##
##           Did you remember to:                                      ##
##             * Edit $users with your hostmask?                       ##
##             * Set the optional $config variables if you would like? ##
##                                                                     ##
#########################################################################
#########################################################################

#die( "\r\n" . chr(27) . "[01;91mSTOP! ". chr(27) . "[0mThe bot has not been configured.  " . chr(27) . "[01;92mPlease configure YamaBot.conf.php correctly.". chr(27) ."[0m\r\n\r\n");

#########################################################################
#LEISURE: Add colored text capability.  Inconsequential, but aesthetic###
#########################################################################

$color['none'  ] = chr(27) . "[0m";
$color['dark'  ] = chr(27) . "[01;90m";
$color['red'   ] = chr(27) . "[01;91m";
$color['green' ] = chr(27) . "[01;92m";
$color['yellow'] = chr(27) . "[01;93m";
$color['blue'  ] = chr(27) . "[01;94m";
$color['pink'  ] = chr(27) . "[01;95m";
$color['cyan'  ] = chr(27) . "[01;96m";

$underlined     = chr(27) . "[01;4m";

#Note: rev stands for "reverse" as in the
#      background is hilighted instead of
#      the actual text.

$rev['bold'  ] = chr(27) . "[01;1m";
$rev['dark'  ] = chr(27) . "[01;5m";
$rev['light' ] = chr(27) . "[01;7m";
$rev['red'   ] = chr(27) . "[01;41m";
$rev['green' ] = chr(27) . "[01;42m";
$rev['yellow'] = chr(27) . "[01;43m";
$rev['blue'  ] = chr(27) . "[01;44m";
$rev['pink'  ] = chr(27) . "[01;45m";
$rev['cyan'  ] = chr(27) . "[01;46m";

$bold_light_bold = chr(27) . "[01;47m";

#########################################################################
#REQUIRED: Function to check eval'd code for errors (from the php.net website)
#########################################################################
if(!$rehash){

function eval_syntax($code)
{
    $braces = 0;
    $inString = 0;

    // We need to know if braces are correctly balanced.
    // This is not trivial due to variable interpolation
    // which occurs in heredoc, backticked and double quoted strings
    foreach (token_get_all('<?php ' . $code) as $token)
    {
        if (is_array($token))
        {
            switch ($token[0])
            {
            case T_CURLY_OPEN:
            case T_DOLLAR_OPEN_CURLY_BRACES:
            case T_START_HEREDOC: ++$inString; break;
            case T_END_HEREDOC:   --$inString; break;
            }
        }
        else if ($inString & 1)
        {
            switch ($token)
            {
            case '`':
            case '"': --$inString; break;
            }
        }
        else
        {
            switch ($token)
            {
            case '`':
            case '"': ++$inString; break;

            case '{': ++$braces; break;
            case '}':
                if ($inString) --$inString;
                else
                {
                    --$braces;
                    if ($braces < 0) return false;
                }

                break;
            }
        }
    }

    if ($braces) return false; // Unbalanced braces would break the eval below
    else
    {
        ob_start(); // Catch potential parse error messages
        $code = eval('if(0){' . $code . '}'); // Put $code in a dead code sandbox to prevent its execution
        ob_end_clean();

        return false !== $code;
    }
}
} # !$rehash

#########################################################################
#REQUIRED: sha512 pass for the bot, which will be used in authorization
#          to initially start it up
#
#NOTE: to generate a sha512 hash, type the following into the terminal
#      php -r 'hash(sha512,"myText");'
#      OR
#      ./YamaBot.php -hash
#########################################################################

$realpass="0a50261ebd1a390fed2bf326f2673c145582a6342d523204973d0219337f81616a8069b012587cf5635f6925f1b56c360230c19b273500ee013e030601bf2425";

	#hashes to foobar

?>
